﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="jlparing3_paring", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Jlparing3Paring))]
    public class Jlparing3ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IJlparing3Paring clazz;
        
        public Jlparing3ParingSerializer(IJlparing3Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Juhiloanr!=null) {
                Writer.WriteStartElement("juhiloanr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Juhiloanr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Perekonnanimi!=null) {
                Writer.WriteStartElement("perekonnanimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perekonnanimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Isikukood!=null) {
                Writer.WriteStartElement("isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "juhiloanr")) {
                goto juhiloanr;
            }
            else {
                if ((Reader.LocalName == "eesnimi")) {
                    goto eesnimi;
                }
                else {
                    if ((Reader.LocalName == "perekonnanimi")) {
                        goto perekonnanimi;
                    }
                    else {
                        if ((Reader.LocalName == "isikukood")) {
                            goto isikukood;
                        }
                        else {
                            return;
                        }
                    }
                }
            }
        juhiloanr:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>jlparing3_paring>juhiloanr");
            }
            clazz.Juhiloanr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("juhiloanr")).Value;
            goto START;
        eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>jlparing3_paring>eesnimi");
            }
            clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            goto START;
        perekonnanimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>jlparing3_paring>perekonnanimi");
            }
            clazz.Perekonnanimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perekonnanimi")).Value;
            goto START;
        isikukood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>jlparing3_paring>isikukood");
            }
            clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            goto START;
        }
    }
}
